<?php
	include_once('../admin/config.php');
	
	if (!empty($_POST))
	{
		$tag = $_POST['tag_en'];
		
		$tag_id = getTagIDByName($tag, 'en');
		
		$tag_name = getTagNameByID($tag_id, 'ru');
		
		$video['video'] = getAllVideoWithTag($tag_id);
		
		foreach ($video['video'] as $one_video)
		{
			$one_video_with_tag['video_id'] = $one_video;
			$one_video_with_tag['preview_id'] = getVimeoIDbyVideoID($one_video);
			$video_with_tag['video'][] = $one_video_with_tag;
		}
		
		$video_with_tag['tag_name'] = $tag_name;
		$video_with_tag['preview_dir'] = $short_preview_dir;
		
		echo json_encode($video_with_tag);
	}
	else
	{
		exit();
	}
?>